package com.ttg.security;

import com.ttg.contants.PayContants;
import com.ttg.contants.TestContants;
import com.ttg.utils.connection.HttpClientUtils;

import java.util.HashMap;
import java.util.Map;

public class EncryptionUtils {

    public static String encryption(Map map){
        //过滤掉不参于签名的字段
        Map param = HttpClientUtils.paramFilter(map, PayContants.SIGNATUREINFO,PayContants.SIGNATUREALGORITHM);
        String tmp = HttpClientUtils.createLinkString(param);
        return RSA.signByPri(tmp, TestContants.PRIVATE_KEY,TestContants.CHARSET_UTF8);
    }

    public static void main(String[] args) {

        Map map = new HashMap();
        map.put("merchantId","10000");
        map.put("merOrderId","201607191749");
        map.put("batchNo","0114689228369500");
        map.put("flag","");
        map.put("termType","07");
        map.put("purpose","店管家");
        map.put("approver","zhangdi");

        System.out.println(encryption(map));


    }
}
